package com.wx.gof.pattern.behavioral.command;


import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName Invoker
 * @Author wx
 * @Description 调用者
 * @Date 2018-12-14-23:30
 */
public class Invoker {
    private List<ICommand> iCommandList = new ArrayList<>();

    /**
     * @param iCommand
     * @methodName: addCommand
     * @author: wx
     * @description: 添加命令
     * @date: 2018/12/14
     * @return: void
     */
    public void addCommand(ICommand iCommand) {
        this.iCommandList.add(iCommand);
    }

    /**
     * @param
     * @methodName: executeCommand
     * @author: wx
     * @description: 执行命令
     * @date: 2018/12/14
     * @return: void
     */
    public void executeCommand() {
        this.iCommandList.forEach(command -> {
            command.execute();
        });
    }

}
